//
//  CarView_Froum.m
//  CarHome
//
//  Created by 小伍 on 14-9-24.
//  Copyright (c) 2014年 WJN_work@163.com. All rights reserved.
//

#import "CarView_Froum.h"
#import "BBSViewController.h"
#import "KindofCarModel.h"
@class ForumViewController;
@implementation CarView_Froum
- (void)dealloc
{
    [_carView release];
    _carView = nil;
    [_carTableView release];
    _carTableView = nil;
    [_carView release];
    _carView = nil;
    [_arr release];
    _arr = nil;
    [super dealloc];
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _carArray = [[NSMutableArray alloc]init];
        _arr = [[NSMutableArray alloc]init];
    
        self.carTableView = [[UITableView alloc]initWithFrame:CGRectMake(0,0, 320 - 80, 480) style:UITableViewStylePlain];
        [self.carTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
        [_carTableView setSeparatorColor:[UIColor redColor]];
        self.carTableView.delegate = self;
        self.carTableView.dataSource = self;
        [self.carTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"a"];
        [self addSubview:self.carTableView];
        
    }
    return self;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_carArray count];
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"a"];
    ;
    [cell.textLabel setText:[[_carArray objectAtIndex:indexPath.row]objectForKey:@"bbsname"]];
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString * bbsid =[NSString stringWithFormat:@"%@",[[_carArray objectAtIndex:indexPath.row]objectForKey:@"bbsid"]];

    NSString * bbsname =[NSString stringWithFormat:@"%@",[[_carArray objectAtIndex:indexPath.row]objectForKey:@"bbsname"]];
    KindofCarModel * kindModel = [[KindofCarModel alloc]init];
    kindModel.bbsname = bbsname;
    kindModel.bbsid = bbsid;
    [[NSNotificationCenter defaultCenter] postNotificationName:@"ccc" object:kindModel];

    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
